package br.org.ifrr.controller;

import java.io.Serializable;

import javax.faces.bean.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;

import br.org.ifrr.model.Gestor;
import br.org.ifrr.model.TipoDepartamento;
import br.org.ifrr.service.CadastroGestorService;
import br.org.ifrr.util.jsf.FacesUtil;

@Named
@ViewScoped
public class CadastroGestorBean implements Serializable {

	private static final long serialVersionUID = 1L;

	@Inject
	private CadastroGestorService cadastroGestorService;

	private Gestor gestor;

	public CadastroGestorBean() {
		limpar();
	}

	private void limpar() {
		gestor = new Gestor();
	}

	public void salvar() {
		this.gestor = cadastroGestorService.salvar(this.gestor);
		limpar();

		FacesUtil.addInfoMessage("Gestor salvo com sucesso.");
	}

	public boolean isEditando() {

		return this.gestor.getId() != null;
	}

	public Gestor getGestor() {
		return gestor;
	}

	public void setGestor(Gestor gestor) {
		this.gestor = gestor;
	}
	
	public TipoDepartamento[] getTipoDepartamentos() {
		return TipoDepartamento.values();
	}
	
	
	/*
	 * public void tipoPessoaAlterado(ValueChangeEvent event) {
	 * 
	 * this.Gestor.setTipo((TipoPessoa) event.getNewValue());
	 * 
	 * FacesContext.getCurrentInstance().renderResponse(); /*
	 * if(event.getNewValue() == TipoPessoa.FISICA){
	 * this.pessoa.setTipo((TipoPessoa)event.getNewValue()); }
	 */
}
